<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<!-- <script src='/Public/jquery.min.js'></script> -->
  <script src="https://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
  
	<script src='/Public/foundation/js/foundation.min.js'></script>
	<link rel="stylesheet" href="/Public/foundation/css/foundation.min.css">
  <script src='/Public/jquery.cityselect.js'></script>
  <script src='/Public/jquery.datetimepicker.full.js'></script>
  <link rel="stylesheet" href="/Public/jquery.datetimepicker.css">
   <script src="http://cdn.static.runoob.com/libs/foundation/5.5.3/js/vendor/modernizr.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<nav class="top-bar" data-topbar>
  <ul class="title-area">
    <li class="name">
      <h1><a href="#">后台管理</a></h1>
    </li>
  </ul>

  <section class="top-bar-section">
    <ul class="right">
      <li><a href=""><?php echo (session('name')); ?></a></li>
      <li><a href="<?php echo U('Login/doLogout');?>">退出</a></li>
    </ul>
  </section>
</nav>

<div class="small-2 columns">
<ul class="side-nav">
 <?php if(is_array($nav)): $i = 0; $__LIST__ = $nav;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li><a href="<?php echo U($vo['url']);?>" target='<?php echo ($vo["target"]?"_blank":null); ?>'><?php echo ($vo["mname"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
    </ul>
</div>
<div class="small-10 columns">

<link rel="stylesheet" href="http://static.runoob.com/assets/foundation-icons/foundation-icons.css">
<link rel="stylesheet" href="/Public/jquery.datetimepicker.css">
	<!-- <input type="text" id="datetimepicker2"/> -->
	<br>
	<div class='row'>
		<form action="?" method="post" id='form'>
			<div class='medium-4 columns'>
				<input id="datetimepicker2" type="text" name='points_time' value='<?php echo ($time); ?>'>
			</div>
			<div class='medium-4 columns'>
				<select name="term_id" id="term_id">
					<?php if(is_array($term)): $i = 0; $__LIST__ = $term;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["val"]); ?>" <?php echo ($nowTerm == $vo['val']?'selected':null); ?>><?php echo ($vo["val"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
				</select>
			</div>
			<div class='medium-4 columns'>
				<input type="text" name='sname' id='sname' value='<?php echo ($sname); ?>'>
			</div>
		</form>
	</div>
	<div class="row">
		
			<table class='medium-12 columns'>
				<tr>
					<th>姓名</th>
					<?php if(is_array($article)): $i = 0; $__LIST__ = $article;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$articleTitle): $mod = ($i % 2 );++$i;?><th><?php echo ($articleTitle["rule_name"]); ?></th><?php endforeach; endif; else: echo "" ;endif; ?>
				</tr>
				<?php if(is_array($student)): $i = 0; $__LIST__ = $student;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr index='<?php echo ($vo["student_id"]); ?>'>
					<th><?php echo ($vo["sname"]); ?></th>
					<?php if(is_array($article)): $i = 0; $__LIST__ = $article;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vv): $mod = ($i % 2 );++$i;?><td index='<?php echo ($vv["points_rules_id"]); ?>'></td><?php endforeach; endif; else: echo "" ;endif; ?>
					</tr><?php endforeach; endif; else: echo "" ;endif; ?>
			</table>
		
	</div>
	<script src='/Public/jquery.datetimepicker.full.js'></script>
	<script>
	var arr = <?php echo ($pointJson); ?>;
	for(index in arr){
		var s = null;
		s = arr[index]['student_id'];
		a = arr[index]['points_rules_id'];
		id = arr[index]['points_id'];
		$('tr[index='+s+'] td[index='+a+']').attr('id',id).html('<i class="fi-check"></i>');
	}
	$('table tr td').click(function(){
		var i,
			s,
			a,
			id,
			data = {};
			if($(this).html()){
				unCheck(this);
			}else{
				check(this);
			}
	});
	var check = function(e){
		time = $('#datetimepicker2').val();
		i = document.createElement('i');
		$(i).prop('class','fi-check');
		$(e).html(i);
		s = $(e).parents('tr').attr('index');
		a = $(e).attr('index');
		data = {student_id:s,points_rules_id:a,points_time:time};
		$.post("<?php echo U('deduct');?>",data,function(data){
			$(e).attr('id',data);
		});
	}
	var unCheck = function(e){
		id = $(e).attr('id');
		console.log(id);
		$(e).html(null);
		data = {id:id};
		$.post("<?php echo U('editCredit');?>",data,function(data){

		});
	}
	$("#datetimepicker2,#term_id,#sname").blur(function(){
		$('#form').submit();
	});
	$('#datetimepicker2').datetimepicker({
		lang:'ch',
		timepicker:false,
		format:'Y-m-d',
		formatDate:'Y/m/d',
		minDate:'2000/01/01', // yesterday is minimum date
		maxDate:'2020/12/31' // and tommorow is maximum date calendar
	});
	</script>

</div>

</body>
</html>